// hash就可以解决
; (function () {
    //return
    /**
   * @param {string} ransomNote
   * @param {string} magazine
   * @return {boolean}
   */
    var canConstruct = function (ransomNote, magazine) {
        let obj = {}
        for (const iterator of ransomNote) {
            if (obj[iterator]) {
                obj[iterator]++
            } else {
                obj[iterator] = 1
            }
        }

        for (const iterator of magazine) {
            if (obj[iterator]) {
                obj[iterator]--
                if (obj[iterator] == 0) {
                    delete obj[iterator]
                }
            }
        }
        console.log(Object.keys(obj));
        return Object.keys(obj).length == 0

    };

    canConstruct('a', 'b')
})();